package cn.cdeden.resource.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.Analyzer;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.HighLightTypeEnum;
import org.dromara.easyes.annotation.rely.IdType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 文档实体
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@IndexName(value = "sysosses") //attachment
public class SysOssEs implements Serializable {


    private static final long serialVersionUID = 1L;

    /**
     * es中的唯一id
     */
    // 将alarmId设置为唯一id
    @IndexId(type = IdType.NONE)
    @IndexField(value = "id")
    private String id;

    @IndexField(value = "ossId")
    private String ossId;

    /**
     * 租户id
     */
    @IndexField(value = "tenantId")
    private String tenantId;

   /**
     * 文档类型
     */
    @IndexField(value = "type")
    private String type;

    /**
     * 团队编号
     */
    @IndexField(value = "teamId")
    private String teamId;

    /**
     * 模块id
     */
    @IndexField(value = "moduleId")
    private String moduleId;

    /**
     * 文档标题
     */
    @IndexField(value = "title",fieldType = FieldType.TEXT, analyzer = Analyzer.IK_MAX_WORD)
    @HighLight(
//        mappingField = "title", // 自定义mapping
        numberOfFragments= 5, // 显示的片段数量
//        preTag= "<em>", postTag = "</em>" , // 高亮标签
        highLightType = HighLightTypeEnum.PLAIN ,
        fragmentSize = 200 // 片段长度
    )
    private String title;

    /**
     * 文件后缀名
     */
    private String fileSuffix;

    /**
     * 文档内容
     */
    @HighLight(
//        mappingField = "content", // 自定义mapping
        numberOfFragments= 2, // 显示的片段数量
//        preTag= "<em>", postTag = "</em>" , // 高亮标签
        highLightType = HighLightTypeEnum.PLAIN ,
        fragmentSize = 50 // 片段长度
    )
    @IndexField(value = "attachment.content",fieldType = FieldType.TEXT, analyzer = Analyzer.IK_MAX_WORD)
    private String content;

    /**
     * 文件路径
     */
    @IndexField(value = "filePath")
    private String filePath;

    /**
     * 模块类型
     */
    @IndexField(value = "moduleType")
    private String moduleType;

    /**
     * 版本id
     */
    @IndexField(value = "versionId")
    private String versionId;

    /**
     * 版本名称
     */
    @IndexField(value = "versionName")
    private String versionName;


    /**
     * 创建部门
     */
    @IndexField(value = "createDept")
    private Long createDept;

    /**
     * 创建者
     */
    @IndexField(value = "createBy")
    private Long createBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @IndexField(value = "createTime")
    private Date createTime;

    /**
     * 更新者
     */
    @IndexField(value = "updateBy")
    private Long updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @IndexField(value = "updateTime")
    private Date updateTime;


    /**
     * 是否需要权限
     */
    @IndexField(value = "isPurview")
    private String isPurview = "0";

    /**
     * 哪些用户拥有该文件
     */
    @IndexField(value = "userIdList")
    private List<String> userIdList;

    /**
     * 哪些角色拥有该文件
     */
    @IndexField(value = "roleIdList")
    private List<String> roleIdList;

    /**
     * 哪些部门拥有该文件
     */
    @IndexField(value = "deptIdList")
    private List<String> deptIdList;

    /**
     * 哪些岗位拥有该文件
     */
    @IndexField(value = "postIdList")
    private List<String> postIdList;


}
